package resp

const SUCCESS  =0
const ERROR  = 1

type Response struct {
	Result_code int   `json:"result_code"`
	Msg string        `json:"msg"`

	PageSize int		 `json:"pageSize"`
	PageNo int			 `json:"pageNo"`
	TotalCount int			 `json:"totalCount"`
	TotalPage int				 `json:"totalPage"`
	Data interface{}			 `json:"data"`
}

func NewResponse() *Response {
	item:=&Response{}
	item.Result_code=SUCCESS
	return item
}



func (this *Response) SetTotalPage(){

	if this.PageSize<=0{
		this.PageSize=10
	}

	if this.TotalCount<0{
		this.TotalCount=0
		this.TotalPage=0

	}else{

		p_cnt:=this.TotalCount/this.PageSize

		mod:=this.TotalCount%this.PageSize

		if mod>0{
			p_cnt++
		}

		this.TotalPage=p_cnt
	}

}



type SimpleResponse struct {
	Result_code int   `json:"result_code"`
	Msg string        `json:"msg"`
	Data interface{}			 `json:"data"`
}
func NewSimpleResponse() *SimpleResponse {
	item:=&SimpleResponse{}
	item.Result_code=SUCCESS
	return item
}